/**************************************************************************
 *         Copyright(c) 2007 by Sunplus mMedia  Technology Co., Ltd.       *
 *                                                                         *
 *  This software is copyrighted by and is the property of Sunplus mMedia  *
 *  Technology Co., Ltd. All rights are reserved by Sunplus mMedia Techno- *
 *  logy Co., Ltd. This software may only be used in accordance with the   *
 *  corresponding license agreement. Any unauthorized use, duplication,    *
 *  distribution, or disclosure of this software is expressly forbidden.   *
 *                                                                         *
 *  This Copyright notice "M U S T" not be removed or modified without     *
 *  prior written consent of Sunplus mMedia Technology  Co., Ltd.          *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd. reserves the right to modify this  *
 *  software without notice.                                               *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd.                                    *
 *  19-1, Innovation First Road, Science-Based Industrial Park,            *
 *  Hsin-Chu, Taiwan, R.O.C.                                               *
 *                                                                         *
 **************************************************************************/
#ifndef __SP1K_SNAP_API_H__
#define __SP1K_SNAP_API_H__

/** \file sp1k_snap_api.h
 * @brief		Spca1528 snap related interface
 */

/**************************************************************************
 *                           C O N S T A N T S                            *
 **************************************************************************/
typedef enum {
	SP1K_SNAP_PARAM_QUALITY = 0,
	SP1K_SNAP_PARAM_FORMAT,
	SP1K_SNAP_PARAM_BURST,
	SP1K_SNAP_PARAM_QV,
	SP1K_SNAP_PARAM_QV_PERIOD,
	SP1K_SNAP_PARAM_PRE_BRC,
	SP1K_SNAP_PARAM_POST_BRC,
	SP1K_SNAP_PARAM_COMPRESS_RATIO,
	SP1K_SNAP_PARAM_ROT_FLIP_OPT,
	SP1K_SNAP_PARAM_SHUTTER_SOUND_OPT,
	SP1K_SNAP_PARAM_DATE_STAMP_OPT,
	SP1K_SNAP_PARAM_DATE_STAMP_TYPE,
	SP1K_SNAP_PARAM_PHOTO_FRM_OPT,
	SP1K_SNAP_PARAM_QV_ROT_OPT,
	SP1K_SNAP_PARAM_SKIP_PV,
	SP1K_SNAP_PARAM_SKIP_STORE,
	SP1K_SNAP_PARAM_QV_EFFECT,
	SP1K_SNAP_PARAM_PV_FREEZE_OPT,
	SP1K_SNAP_PARAM_SAVE_RAW_OPT,
	SP1K_SNAP_PARAM_SAVE_YUV_OPT,
	SP1K_SNAP_PARAM_PH_WIDTH,
	SP1K_SNAP_PARAM_PH_HEIGHT,
	SP1K_SNAP_PARAM_SOUND_LOW_ADDR,
	SP1K_SNAP_PARAM_SOUND_HIGH_ADDR,
	SP1K_SNAP_PARAM_PH_LOW_ADDR,
	SP1K_SNAP_PARAM_PH_HIGH_ADDR,
	SP1K_SNAP_PARAM_BAD_PIXEL_OPT,
	SP1K_SNAP_PARAM_10_BIT_RAW_OPT,
	SP1K_SNAP_PARAM_POST_WB_OPT,
	SP1K_SNAP_PARAM_MULTI_LC_OPT,
	SP1K_SNAP_PARAM_AD_DATE_STAMP_OPT,
	SP1K_SNAP_PARAM_AD_DS_WIDTH,
	SP1K_SNAP_PARAM_AD_DS_HEIGHT,
	SP1K_SNAP_PARAM_AD_DS_LOW_ADDR,
	SP1K_SNAP_PARAM_AD_DS_HIGH_ADDR,
	SP1K_SNAP_PARAM_DS_X_RATIO,
	SP1K_SNAP_PARAM_QV_WIDTH,
	SP1K_SNAP_PARAM_QV_HEIGHT,

	//------INTERNAL OPTION------//
	SP1K_SNAP_PARAM_AUTO_POST_WB_OPT,

	//------DEBUG OPTION------//
	SP1K_SNAP_PARAM_DEBUG_RAW_ONLY,
	SP1K_SNAP_PARAM_MAX
} snapParam_e;

typedef enum {
	SP1K_SNAP_CALLBACK_BURST = 0,
	SP1K_SNAP_CALLBACK_MAX
} snapCallback_e;

typedef enum {
	SP1K_SNAP_MSG_OK = 0,
	SP1K_SNAP_MSG_FILE_WRITE_ERROR,
	SP1K_SNAP_MSG_MAX
} snapMsg_e;

typedef enum {
	SP1K_SNAP_QV_EFFECT_NORMAL = 0,
	SP1K_SNAP_QV_EFFECT_BLACKWHITE,
	SP1K_SNAP_QV_EFFECT_SEPIA,
	SP1K_SNAP_QV_EFFECT_BINARIZE,
	SP1K_SNAP_QV_EFFECT_MAX
} snapQvEffect_e;

typedef enum {
	SNAP_INFO_RAW_BUF_ADDR = 0,
	SNAP_INFO_MAX
} snapInfo_e;

#define SP1K_SNAP_FORMAT_422	0
#define SP1K_SNAP_FORMAT_420	1
#define SP1K_SNAP_FORMAT_400	2

#define SP1K_SNAP_QUALITY_SUPER_FINE	0
#define SP1K_SNAP_QUALITY_FINE			1
#define SP1K_SNAP_QUALITY_NORMAL		2

typedef enum {
	SP1K_SNAP_ICATE_IDLE = 0,
	SP1K_SNAP_ICATE_START,
	SP1K_SNAP_ICATE_SENSOR_FINISH,
	SP1K_SNAP_ICATE_RAW_READY,
	SP1K_SNAP_ICATE_CDSP_READY,
	SP1K_SNAP_ICATE_CDSP_DOING,
	SP1K_SNAP_ICATE_CDSP_FINISH,

	SP1K_SNAP_ICATE_END,

	//xian ++
    SP1K_ICATE_RES_DOWNLOAD,
    SP1K_ICATE_RES_UPLOAD,
	//xian --

    SP1K_ICATE_RAW_DOWNLOAD,
    SP1K_ICATE_YUV_UPLOAD,

    SP1K_SNAP_ICATE_JPG_FINISH,
    SP1K_JPG_UPLOAD,
    
} snapIcateState_e;



/**************************************************************************
 *                              M A C R O S                               *
 **************************************************************************/

/**************************************************************************
 *                          D A T A    T Y P E S                          *
 **************************************************************************/

/**************************************************************************
 *                         G L O B A L    D A T A                         *
 **************************************************************************/

/**************************************************************************
 *                 E X T E R N A L    R E F E R E N C E S                 *
 **************************************************************************/

/**************************************************************************
 *               F U N C T I O N    D E C L A R A T I O N S               *
 **************************************************************************/
// snap_task.c
/**
 * @fn sp1kSnapInit( UINT32 dramMByteSize, UINT32 memoryBeginAddr, UINT32 memoryEndAddr );
 * @brief	initial and configure snap module. It must be taken before any snap action.
 * @param[in] dramMByteSize	 specify the total dram size in unit of megabyte
 * @param[in] memoryBeginAddr      the available dram space starting address for snap flow
 * @param[in] memoryEndAddr	 the available dram space ending address for snap flow
 * @retval error code -  success: 0, fail: 1
 */
UINT8 sp1kSnapInit( UINT32 dramMByteSize, UINT32 memoryBeginAddr, UINT32 memoryEndAddr );

/**
 * @fn UINT8 sp1kSnapTask( void );
 * @brief	It triggers snap flow to capture image.
 * @retval error code -  success: 0, fail: 1
 * @see sp1kSnapParamSet()
 */
UINT8 sp1kSnapTask( void );

/**
 * @fn UINT8 sp1kSnapParamSet( UINT8 attrId, UINT16 value );
 * @brief	It configures snap parameter, such as burst or single, show quickview or not
 * @param[in] attrId	 the parameter id which is defined in snapParam_e
 * @param[in] value      the configure value of snap parameter
 * @retval error code -  success: 0, fail: 1
 * @see sp1kSnapParamGet()
 */
UINT8 sp1kSnapParamSet( UINT8 attrId, UINT16 value );

/**
 * @fn UINT16 sp1kSnapParamGet( UINT8 attrId );
 * @brief	It gets snap parameter which is used to capture image
 * @param[in] attrId	 the parameter id which is defined in snapParam_e
 * @retval the parameter value with 16 bit number
 * @see sp1kSnapParamSet()
 */
UINT16 sp1kSnapParamGet( UINT8 attrId );

/**
 * @fn void sp1kSnapSizeSet( UINT16 xSize, UINT16 ySize );
 * @brief	It configures height and width of image to capture
 * @param[in] xSize	 the horizontal size of the image
 * @param[in] ySize	 the vertical size of the image
 * @retval none
 * @see sp1kSnapSizeGet()
 */
void sp1kSnapSizeSet( UINT16 xSize, UINT16 ySize );

/**
 * @fn void sp1kSnapSizeGet( UINT16* xSize, UINT16* ySize );
 * @brief	It gets height and width of image to capture
 * @param[out] *xSize	 the horizontal size of the image
 * @param[out] *ySize	 the vertical size of the image
 * @retval none
 * @see sp1kSnapSizeSet()
 */
void sp1kSnapSizeGet( UINT16* xSize, UINT16* ySize );//jintao.liu 2008-3-11

/**
 * @fn UINT8 sp1kJpegQTableSet( UINT8 QTableIndex, UINT8 *yQTable, UINT8 *uvQTable, UINT8 zigzagOpt );
 * @brief	It set the Q-table which jpeg uses for encode and decode. It can set with Q index or customized table
 * @param[in] QTableIndex	 the Q-table index. If configures with customized table, set it to 0.
 * @param[in] *yQTable	 the customized y table. Taking effect must be with index is 0
 * @param[in] *uvQTable	 the customized uv table. Taking effect must be with index is 0
 * @param[in] zigzagOpt	 whether set table with zigzag transform. It needs zigzag tranform when tables are from jpeg header. 0: no zigzag transform. 1: zigzag transform.
 * @retval error code -  success: 0, fail: 1
 */
UINT8 sp1kJpegQTableSet( UINT8 QTableIndex, UINT8 *yQTable, UINT8 *uvQTable, UINT8 zigzagOpt );

UINT8 sp1kSnapTurnOnPv( void );
UINT8 sp1kSnapStore( void );
void sp1kSnapCallbackReg( UINT32 id, void *pfunct );

#endif  /* __SP1K_SNAP_API_H__ */

